<template>
  <div class="good">
    <van-swipe-cell :disabled="!isSlide">
      <div class="content">
        <van-checkbox class="choose" 
        v-model="goodData.checked" 
        v-if="isHasCheckbox"
        @change="simpleSelect(goodData.checked)"
        checked-color="#0C34BA"></van-checkbox>
        <div>
          <img :src="goodData.small_img" />
        </div>
        <div class="text" @click="add(goodData.pid)">
          <h3>{{goodData.name}}</h3>
          
          <p>{{goodData.enname}}</p>
          <i>&yen;{{goodData.price}}</i>
        </div>
        <div>
            <h4>{{goodData.rule}}</h4>
        </div>
        <div class="choosenum">
          <slot></slot>
        </div>
      </div>
      <template #right>
        <van-button square type="danger" text="删除" 
        @click="remove"/>
      </template>
    </van-swipe-cell>
  </div>
</template>

<script>
export default {
  name: "Good",
  data() {
    return {
      value: "",
      checked:true
    };
  },
  props:{
      goodData:{
          type:Object,
          default(){
              return{};
          }
      },isSlide: {
        type: Boolean,
        default: true
      },
      isHasCheckbox: {
        type: Boolean,
        default: true
      }
  },
  methods:{
    add(item){
        this.$router.push({name:"Goods",query:{item}})
    },
    simpleSelect() {
        this.$emit('simpleSelect');
    },
    
    remove(){
      this.$emit('remove');
    }
  }
};
</script>

<style lang="less" scoped>
.content {
  display: flex;
  margin-bottom: 5px;
  background-color: #fff;
  height: 110px;
  padding: 5px;
  box-sizing: border-box;
  width: calc(~"100% - 10px");
  margin-left: 5px;
  img{
      width: 100px;
      height: 100px;
  }
  .choose {
    margin: 0px 10px 0 5px;
  }
  .text {
    width: 100px;
    margin-left: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    h3 {
      padding: 5px 0 ;
      margin: 0;
      font-weight: normal;
      display: inline-block;
    }
    
    p {
      padding: 0;
      margin: 0;
      color: gray;
      //   margin-top: 5px;
    }
    i {
      font-style: normal;
      display: block;
      margin-top: 25px;
      font-size: 14px;
      color: rgb(12, 52, 186);
      font-weight: bold;
    }
  }
  .choosenum {
    position: absolute;
    right: 10px;
    margin-top: 65px;
  }
}
h4{
        padding: 0;
        margin: 0;
        display: inline-block;
        // margin-left: 10px;
        margin-top: 6px;
        margin-left: 5px;
        font-size: 8px;
        color: gray;
        font-weight: normal;
    }
/deep/ .van-button {
  height: 100%;
}
</style>